Docker Containers (includes Content Update Program) by Christopher Negus
Author:Christopher Negus
Language: eng
Format: epub
Publisher: Pearson Education Limited (US titles)
Published: 2016-03-16T04:00:00+00:00
Click here to view code image
# docker run -d --name=link-test myrepo/fedora-httpd
Notice that I run the container in detached mode with the -d parameter (and not interactively on a TTY with -it).
Next I run a second container that I name linked and link it to link-test. I’m mapping the link to the name lt (short for link-test). This is the name I use from inside the second container to access port 80 in the first container.
Click here to view code image
# docker run -it --link=link-test:lt --name=linked fedora:22 bash
I don’t have to name this second container, but it’s good practice to do so. From within this second container, running the env (environment) command shows the following:
Click here to view code image
bash-4.2# env
HOSTNAME=d71eb38e62d5
TERM=xterm
LT_PORT_80_TCP=tcp://172.17.0.3:80
LT_PORT_80_TCP_PORT=80
LT_PORT_80_TCP_PROTO=tcp
LT_PORT=tcp://172.17.0.3:80
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
container_uuid=d71eb38e-62d5-0a15-902c-6901a4ed5d26
LT_NAME=/linked/lt
SHLVL=1
HOME=/root
LT_PORT_80_TCP_ADDR=172.17.0.3
_=/usr/bin/env
Notice that there are several environment variables starting with LT. Those variable names are derived from the lt string I assigned to the link name in the docker run command. Any port exposed from the first container is accessible from the new container in the same way.
Now I can use the curl command to leverage the link between the two containers and display the html page available on port 80 of the container named lt or link-test. I only show the first few lines here:
Click here to view code image
bash-4.2# curl http://lt
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/
xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test Page for the Apache HTTP Server on Fedora</title>
...
Links are a powerful tool for linking containers together. In the next section I build up a scenario.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7771)
Filmora Efficient Editing by Alexander Zacharias(5840)
The Infinite Retina by Robert Scoble Irena Cronin(5317)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(4009)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3939)
Edit Like a Pro with iMovie by Regit(3458)
Linux Administration Best Practices by Scott Alan Miller(2863)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2839)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2527)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2428)
Docker on Windows by Stoneman Elton(2322)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2317)
Creative Projects for Rust Programmers by Carlo Milanesi(2275)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2115)
Hands-On Linux for Architects by Denis Salamanca(2056)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(2009)
Computers For Seniors For Dummies by Nancy C. Muir(2006)
The Old New Thing by Raymond Chen(1942)
Linux Kernel Debugging by Kaiwan N Billimoria(1767)
